package cn.edu.hqu.exp.courseselection.web;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import cn.edu.hqu.exp.courseselection.domain.PersonInfo;
import cn.edu.hqu.exp.courseselection.repository.PersonInfoRepository;
import lombok.extern.slf4j.Slf4j;


@Slf4j
@Controller
@RequestMapping("/conclude")
public class ConcludeController {
	private PersonInfoRepository personInfoRepo;
	
	@Autowired
	public ConcludeController(
			PersonInfoRepository personInfoRepo
			) {
		this.personInfoRepo = personInfoRepo;
	}
	
	@GetMapping
	public String showResult(Model model) {
		List <PersonInfo> personInfos = new ArrayList<>();
		personInfoRepo.findAll().forEach(i -> personInfos.add(i));
		model.addAttribute("personInfos",personInfos);
		log.info("person: "+personInfos);
		return "conclude"; 
	}
}
